package com.atguigu.my.chapter01

/**
 *
 * @description: input测试
 * @time: 2020-05-20 17:06
 * @author: baojinlong 
 **/
object VarDemo05 {
  def main(args: Array[String]): Unit = {
    val start = 1
    val end = 100
    var count = 0
    var sum = 0
    for (i <- start to end if i % 9 == 0) {
      count += 1
      sum += i
      println(i)
    }
    printf("count = %d,sum=%d", count, sum)
    // scala推荐使用for,不推荐while.设计思想是使用纯函数来实现,尽量不实用外部变量.
    var i = 0
    while (i < 10) {
      println("hello," + i)
      i += 1
    }
    var index = 10
    do {
      println("hello," + index)
      index += 1
    } while (index < 20)

  }
}